<?php
namespace app\decorate\model;
use app\BaseModel;
use think\facade\Db;



class AdminMeasure extends BaseModel
{
    //定义表名 筛选面积表
    protected $name = 'longbing_card_decorate_m';

    protected $append=[
        'title'
    ];
    /**
     * @param $query
     * 查询范围
     */
    public function scopeStatus($query, $status){
        $query->where('status', '>', $status);
    }

    /**
     * User: chenniang
     * Date: 2019-10-21 10:22
     * @param $vaule
     * @return string
     * descption:加单位
     */
    public function gettitleAttr($value,$data){
        return $data['min'].'-'.$data['max'].'㎡';
    }
    /**
     * @param $dis
     * @return array
     * @throws \think\exception\DbException
     * 面积列表
     */
    public function mList($dis,$page = 10){
        $data = $this->where($dis)->status(-1)->order('sort desc')->paginate($page)->toArray();
        return $data;
    }
    /**
     * @param $dis
     * @return array
     * @throws \think\exception\DbException
     * 面积列表
     */
    public function mselect($dis,$page = 10){
        $data = $this->where($dis)->status(-1)->order('sort desc')->select()->toArray();
        return $data;
    }
    /**
     * @param $data
     * @return int|string
     * 添加面积
     */
    public function mAdd($data){
        $data['create_time'] = time();
        $data['update_time'] = time();
        $res = $this->insert($data);
        return $res;
    }
    /**
     * @param $dis
     * @param $data
     * @return AdminCate
     * 编辑面积
     */
    public function mUpdate($dis,$data){
        $data['update_time'] = time();
        $res = $this->where($dis)->update($data);
        return $res;

    }
    /**
     * @param $dis
     * @return AdminCate
     * 面积详情
     */
    public function mInfo($dis){
        $data = $this->where($dis)->status(-1)->find();
        return !empty($data)?$data->toArray():$data;
    }





}